package org.javaweb.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * 测试用Servlet
 * Created by Administrator on 2016/12/15.
 */
@WebServlet(name="ServletDemo1", urlPatterns = {"/ServletDemo1"})
public class ServletDemo1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String p1 = req.getParameter("p1");
        String p2 = req.getParameter("p2");
        PrintWriter out = resp.getWriter();
        out.print("{p1:" + p1 + ",p2:" + p2 + "}");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String p1 = req.getParameter("p1");
        String p2 = req.getParameter("p2");
        PrintWriter out = resp.getWriter();
        out.print("{p1:" + p1 + ",p2:" + p2 + "}");
    }
}
